package qx.hyj.petrescue.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import qx.hyj.petrescue.entity.Family;
import qx.hyj.petrescue.entity.Users;
import qx.hyj.petrescue.entity.Volunteer;

import java.util.List;

@Repository
public interface Usermapper {
    List<Users> searchByColumn(Users user);
    List<Users> getUsers(Integer ID);
    Users selectUserByphone(String phone);
    public Users login(@Param("account")String account);
    public Integer addUser(@Param("user") Users user);
    Integer updateUser(@Param("user") Users user,@Param("condition") Users condition);
    Users searchById(Integer id);

    @Insert("insert into family (name, phone, email, home,userid) " +
            "values (#{name}, #{phone}, #{email}, #{home},#{userid})")
    Integer addFamily(Family family);

    @Insert("insert into volunteer (name, phone, email,userid) " +
            "values (#{name}, #{phone}, #{email},#{userid})")
    Integer addVolunteer(Volunteer volunteer);

    @Select("select * from family where phone = #{phone} ")
    Integer searchFamilyByPhone(String phone);

    @Select("select * from volunteer where phone = #{phone} ")
    Integer searchVolunteerByPhone(String phone);
}
